﻿using Pay.DTO;
using Pay.IService;
using Pay.TO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Pay.Web.Areas.Admin.Controllers
{
    /// <summary>
    /// 集市订单
    /// </summary>
    [RouteArea("admin")]
    [RoutePrefix("BazaarOrder")]
    public class BazaarOrderController : AdminController
    {
        private ITokenBazaarOrderService _iTokenBazaarOrderService;
        public BazaarOrderController(ITokenBazaarOrderService iTokenBazaarOrderService) {
            _iTokenBazaarOrderService = iTokenBazaarOrderService;
        }
        /// <summary>
        /// 订单列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult Gets(BazaarOrderQuery query) {
            var result = _iTokenBazaarOrderService.Gets(query);
            return Json(ResultToJson.Json(result), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult Get(long id) {
            var result = _iTokenBazaarOrderService.Get(id);
            return Json(ResultToJson.Json(result), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        ///系统取消订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult Cancle(long id) {
            var result = _iTokenBazaarOrderService.SysCancle(id,currentUser.user_id);
            return Json(ResultToJson.Json(result?"取消交易成功":"取消交易失败",result), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 系统确认收货
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult Receive(long id) {
            var result = _iTokenBazaarOrderService.SysReceive(id, currentUser.user_id);
            return Json(ResultToJson.Json(result?"确认收货成功":"确认收货失败",result), JsonRequestBehavior.AllowGet);
        }
    }
}